using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using ODX.Core;

namespace EnGen
{
    public partial class EnGen : Form
    {
        public EnGen()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            OpenFileDialog opf = new OpenFileDialog();
            if ( opf.ShowDialog() == DialogResult.OK )
            {
                lbTypes.Items.Add(opf.FileName);
            }

        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            lbTypes.Items.Remove(lbTypes.SelectedItem);
        }

        private void btnGen_Click(object sender, EventArgs e)
        {
            string cb = Assembly.GetEntryAssembly().Location;
            Assembly a = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "ODX.Core.Mobile.dll"));
            foreach ( Type tp in a.GetTypes() )
                Debug.WriteLine(tp.FullName);

            Type t = a.GetType("ODX.Core.Entity");

            Session s = new Session();
            foreach ( string fn in lbTypes.Items )
                s.RegisterAssembly(
                    Assembly.LoadFile(fn));

            s.Prepare();
        }
    }
}